<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>登录 - {{.config.WebName}}</title>
    <link rel="icon" href="static/admin/favicon.ico" type="image/ico">
    <meta name="keywords" content="{{.config.KeyWord}}">
    <meta name="description" content="{{.config.SiteDescription}}">
    <meta name="author" content="{{.config.WebName}}">
    <link href="static/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="static/admin/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="static/admin/css/style.min.css" rel="stylesheet">
    <style>
        body {
            display: -webkit-box;
            display: flex;
            -webkit-box-pack: center;
            justify-content: center;
            -webkit-box-align: center;
            align-items: center;
            height: 100%;
        }
        .login-box {
            display: table;
            table-layout: fixed;
            overflow: hidden;
            max-width: 700px;
        }
        .login-left {
            display: table-cell;
            position: relative;
            margin-bottom: 0;
            border-width: 0;
            padding: 45px;
        }
        .login-left .form-group:last-child {
            margin-bottom: 0px;
        }
        .login-right {
            display: table-cell;
            position: relative;
            margin-bottom: 0;
            border-width: 0;
            padding: 45px;
            width: 50%;
            max-width: 50%;
            background: #67b26f!important;
            background: -moz-linear-gradient(45deg,#67b26f 0,#4ca2cd 100%)!important;
            background: -webkit-linear-gradient(45deg,#67b26f 0,#4ca2cd 100%)!important;
            background: linear-gradient(45deg,#67b26f 0,#4ca2cd 100%)!important;
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#67b26f', endColorstr='#4ca2cd', GradientType=1 )!important;
        }
        .login-box .has-feedback.feedback-left .form-control {
            padding-left: 38px;
            padding-right: 12px;
        }
        .login-box .has-feedback.feedback-left .form-control-feedback {
            left: 0;
            right: auto;
            width: 38px;
            height: 38px;
            line-height: 38px;
            z-index: 4;
            color: #dcdcdc;
        }
        .login-box .has-feedback.feedback-left.row .form-control-feedback {
            left: 15px;
        }
        @media (max-width: 576px) {
            .login-right {
                display: none;
            }
        }
    </style>
</head>

<body style="background-image: url('http://cdn.mikepudding.com/mybed/admin/images/login-bg-2.jpg'); background-size: cover;">
<div class="bg-translucent p-10">
    <div class="login-box bg-white clearfix">
        <div class="login-left">
            <form action="#!" id="loginForm">
                <div class="form-group has-feedback feedback-left">
                    <input type="text" placeholder="请输入您的用户名" autocomplete="off" class="form-control" name="username" id="username" />
                    <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
                </div>
                <div class="form-group has-feedback feedback-left">
                    <input type="password" placeholder="请输入密码" class="form-control" id="password" name="password" />
                    <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
                </div>
{{/*                <div class="form-group has-feedback feedback-left row">*/}}
{{/*                    <div class="col-xs-7">*/}}
{{/*                        <input type="text" name="captcha" class="form-control" placeholder="验证码">*/}}
{{/*                        <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>*/}}
{{/*                    </div>*/}}
{{/*                    <div class="col-xs-5">*/}}
{{/*                        <img src="static/admin/images/captcha.png" class="pull-right" id="captcha" style="cursor: pointer;" onclick="this.src=this.src+'?d='+Math.random();" title="点击刷新" alt="captcha">*/}}
{{/*                    </div>*/}}
{{/*                </div>*/}}
{{/*                <div class="form-group">*/}}
{{/*                    <label class="lyear-checkbox checkbox-primary m-t-10">*/}}
{{/*                        <input type="checkbox"><span>5天内自动登录</span>*/}}
{{/*                    </label>*/}}
{{/*                </div>*/}}
                <div class="form-group">
                    <button class="btn btn-block btn-primary" type="button" onclick="checkUser();">立即登录</button>
                </div>
            </form>
        </div>
        <div class="login-right">
{{/*            <p><img src="static/admin/images/logo.png" class="m-b-md m-t-xs" alt="logo"></p>*/}}
            <p class="text-white m-tb-15">{{.config.SiteDescription}}</p>
            <p class="text-white">Copyright © 2020 <a href="{{.config.WebUrl}}">{{.config.WebName}}</a>. All right reserved</p>
        </div>
    </div>
</div>
<script type="text/javascript" src="static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="static/admin/js/bootstrap.min.js"></script>
<script src="static/admin/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="static/admin/js/lightyear.js"></script>
<script type="text/javascript">
    function checkUser() {
        lightyear.loading('show');  // 显示
        var username = document.getElementById("username").
            value;
        var password = document.getElementById("password").
            value;

        if (username == "" )
        {
            lightyear.loading('hide');  // 隐藏
            lightyear.notify('用户名不能为空！', 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
            return false;
        }
        if (password == "" )
        {
            lightyear.loading('hide');  // 隐藏
            lightyear.notify('密码不能为空！', 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
            return false;
        }
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/login" ,//url
            data: $('#loginForm').serialize(),
            success: function (result) {
                lightyear.loading('hide');  // 隐藏
                console.log(result);//打印服务端返回的数据(调试用)
                if (result.resultCode == 200) {
                    lightyear.notify('登陆成功，页面即将自动跳转~', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
                    setTimeout(function () {
                        window.location.href = result.url;
                    },1000)
                }else{
                    lightyear.notify('异常！'+result.errorMsg, 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
                }
            },
            error : function(result) {
                console.log(result.errorMsg)
                lightyear.loading('hide');  // 隐藏
                lightyear.notify('异常！' + result.errorMsg, 'warning', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
            }
        });
    }
</script>
</body>
</html>